/*
 *   SPDX-FileCopyrightText: 2021 Jan Blackquill <uhhadd@gmail.com>
 *
 *   SPDX-License-Identifier: LGPL-2.0-only
 */
import QtQuick 2.5
import QtQuick.Controls 2.5 as QQC2
import QtQuick.Layouts 1.1
import org.kde.kirigami 2.13 as Kirigami

Kirigami.BasicListItem {
    id: delegate

    property bool showArrow: false
    property bool selected: delegate.highlighted || delegate.pressed
    property bool isSearching: false

    // Dummy item to make leadingPadding value manipulable by clients
    leading: Item {
        width: 0
    }
    leadingPadding: 0

    icon: {
	if (model.display === 'Соединения')
		return Qt.resolvedUrl('../images/16.svg');
	if (model.display === 'Сетевые диски')
		return Qt.resolvedUrl('../images/17.svg');
    if (model.display === 'Приложения')
		return Qt.resolvedUrl('../images/11.svg');
	switch(model.iconName) {
		case 'preferences-desktop-theme-global': return Qt.resolvedUrl('../images/01.svg')
		case 'preferences-desktop': return Qt.resolvedUrl('../images/02.svg')

		case 'preferences-system-windows': return Qt.resolvedUrl('../images/03.svg')
		case 'preferences-desktop-keyboard-shortcut': return Qt.resolvedUrl('../images/04.svg')

		case 'preferences-system-login': return Qt.resolvedUrl('../images/05.svg')
		case 'preferences-desktop-search': return Qt.resolvedUrl('../images/06.svg')
		case 'preferences-system-users': return Qt.resolvedUrl('../images/07.svg')
		case 'preferences-desktop-notification-bell': return Qt.resolvedUrl('../images/08.svg')
		case 'preferences-desktop-locale': return Qt.resolvedUrl('../images/09.svg')
		case 'preferences-system-time': return Qt.resolvedUrl('../images/10.svg')
		case 'preferences-all': return Qt.resolvedUrl('../images/11.svg')
		case 'preferences-desktop-accessibility': return Qt.resolvedUrl('../images/12.svg')
		case 'kwalletmanager': return Qt.resolvedUrl('../images/13.svg')
		case 'preferences-online-accounts': return Qt.resolvedUrl('../images/14.svg')
		case 'preferences-system-network': return Qt.resolvedUrl('../images/15.svg')
		case 'preferences-system-network': return Qt.resolvedUrl('../images/16.svg')
		case 'preferences-system-network-disk': return Qt.resolvedUrl('../images/17.svg')
		case 'preferences-desktop-mouse': return Qt.resolvedUrl('../images/18.svg')
		case 'preferences-desktop-display': return Qt.resolvedUrl('../images/19.svg')
		case 'kmix': return Qt.resolvedUrl('../images/20.svg')
		case 'preferences-system-power-management': return Qt.resolvedUrl('../images/21.svg')
		case 'preferences-system-bluetooth': return Qt.resolvedUrl('../images/22.svg')
		case 'drive-removable-media': return Qt.resolvedUrl('../images/23.svg')
		case 'preferences-devices-printer': return Qt.resolvedUrl('../images/24.svg')
		case 'ktip': return Qt.resolvedUrl('../images/25.svg')
		case 'drakauth-mdk': return Qt.resolvedUrl('../images/26.svg')
		case 'drakfirewall': return Qt.resolvedUrl('../images/27.svg')
		case 'userdrake': return Qt.resolvedUrl('../images/28.svg')
		case 'system-run': return Qt.resolvedUrl('../images/29.svg')
		case 'harddrake': return Qt.resolvedUrl('../images/30.svg')
		case 'preferences-desktop': return Qt.resolvedUrl('../images/31.svg')
	}
	return model.iconName;
    }
    text: model.display
    labelItem.color: '#000'
    Accessible.name: model.display
    Accessible.onPressAction: clicked()

    trailing: RowLayout {
        Rectangle {
            id: defaultIndicator
            radius: width * 0.5
            implicitWidth: Kirigami.Units.largeSpacing
            implicitHeight: Kirigami.Units.largeSpacing
            visible: model.showDefaultIndicator && systemsettings.defaultsIndicatorsVisible
            Kirigami.Theme.colorSet: Kirigami.Theme.View
            color: Kirigami.Theme.neutralTextColor
        }

        // Extra wrapper to make the defaultIndicator line up vertically for all items
        Item {
            Layout.alignment: Qt.AlignVCenter
            Layout.preferredWidth: Kirigami.Units.iconSizes.small
            Layout.preferredHeight: Kirigami.Units.iconSizes.small

            Kirigami.Icon {
                id: arrow
                anchors.fill: parent
                opacity: 0.7
                source: LayoutMirroring.enabled ? "go-next-symbolic-rtl" : "go-next-symbolic"
                visible: delegate.showArrow
                selected: delegate.selected
            }
        }
    }
}
